home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / spacewar / updobjs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-31  |  1.2 KB  |  51 lines

  1. /*
  2.  * Spacewar - update movement of objects
  3.  *
  4.  * Copyright 1985 obo Systems, Inc.
  5.  * Copyright 1985 Dan Rosenblatt
  6.  */
  7.  
  8. #include "spacewar.h"
  9. #include "universe.h"
  10. #include "obj.h"
  11.  
  12. VOID updobjs()
  13. {
  14.     register struct obj *pobj;
  15.     double tmpvec[3];
  16.     int i;
  17.  
  18. #ifdef DEBUG
  19.     DBG("updobjs()\n");
  20. #endif
  21.  
  22.     for (pobj=objlst;pobj < objlst+MAXOBJ;++pobj) {
  23.  
  24.         /* new orbital center relative plane theta */
  25.         if (pobj->oj_oprd) {
  26.         pobj->oj_ocrpt = ADD(pobj->oj_ocrpt,
  27.         DIV(TWOPI,FLOAT(pobj->oj_oprd)));
  28.         pobj->oj_ocrpt = FMOD(pobj->oj_ocrpt,TWOPI);
  29.         }
  30.  
  31.         /* new position by converting from spherical to rectangular, */
  32.         /* rotating from orbital plane, and translating from orbital */
  33.         /* center; figure velocity from old and new position     */
  34.         vcopy(tmpvec,pobj->oj_pstn);
  35.         pobj->oj_pstn[0] = FLOAT(pobj->oj_orad);
  36.         pobj->oj_pstn[1] = pobj->oj_ocrpt;
  37.         pobj->oj_pstn[2] = DIV(PI,2.);
  38.         sptort(pobj->oj_pstn,pobj->oj_pstn);
  39.         vecmul(pobj->oj_pstn,pobj->oj_rmat,pobj->oj_pstn);
  40.         for (i=0;i < 3;++i)
  41.         pobj->oj_pstn[i] = ADD(pobj->oj_pstn[i],
  42.         pobj->oj_octr.ip_ptr->uv_pstn[i]);
  43.         vchngd(pobj->oj_univ.ip_ptr);
  44.         vdiff(pobj->oj_pstn,tmpvec,pobj->oj_vel);
  45.     }
  46.  
  47. #ifdef DEBUG
  48.     VDBG("updobjs return\n");
  49. #endif
  50. }
  51.